#include "rclcpp/rclcpp.hpp"
#include "route_interfaces/srv/route.hpp"

class route_sever : public rclcpp::Node
{
private:
    /* data */
    rclcpp::Service<route_interfaces::srv::Route>::SharedPtr server;
    rclcpp::CallbackGroup::SharedPtr route_group_server_;
    void route_call_back(const route_interfaces::srv::Route::Request::SharedPtr request, const route_interfaces::srv::Route::Response::SharedPtr response)
    {
        //路由处理
        RCLCPP_INFO(this->get_logger(),"get map,start routing.");
        response -> step = request -> map;
    }
public:
    route_sever(std::string srv_name);
};

route_sever::route_sever(std::string srv_name):Node(srv_name)
{
    RCLCPP_INFO(this->get_logger(),"route server start.");
    RCLCPP_INFO(this->get_logger(),"writing for request.");
    route_group_server_ = this -> create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
    server = this->create_service<route_interfaces::srv::Route>("route_server",std::bind(&route_sever::route_call_back,this,std::placeholders::_1,std::placeholders::_2), rmw_qos_profile_default, route_group_server_);
}

int main(int argc, char **argv)
{
    rclcpp::init(argc,argv);
    auto node = std::make_shared<route_sever>("route_server");
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}

